/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "Moon.h"

namespace PQEngine
{
	const Ogre::String Moon::ENTITY_NAME = "Env/Moon/Entity";
	const Ogre::String Moon::MESH_NAME = "Env/Moon/Mesh";
    const Ogre::String Moon::MATERIAL_NAME = "Env/Moon/Material";
	const Ogre::String Moon::MATERIAL_BACKGROUND_NAME = "Env/Moon/MaterialBackground";

	Moon::Moon(SceneObject* sceneObject)
		: SkyLight(sceneObject)
	{
		initMaterial();
		initBillboards();

		_sceneNode->attachObject(_moonBillboards);
		_sceneNode->attachObject(_backgroundBillboards);

	}

	void Moon::initMaterial()
	{
		 // Clone materials
		Ogre::MaterialPtr ptr=Ogre::MaterialManager::getSingletonPtr()->getByName(MATERIAL_NAME);
		if(ptr.isNull()){
			return;
		}
		/*
		_material=ptr->clone(MATERIAL_CLONE_NAME);
		_material->load();

        mMoonMaterial.reset(InternalUtilities::checkLoadMaterialClone(MOON_MATERIAL_NAME, MOON_MATERIAL_NAME + uniqueSuffix));
        mBackMaterial.reset(InternalUtilities::checkLoadMaterialClone(MOON_BACKGROUND_MATERIAL_NAME, MOON_BACKGROUND_MATERIAL_NAME + uniqueSuffix));

        mParams.setup(mMoonMaterial->getBestTechnique ()->getPass (0)->getFragmentProgramParameters ());

		setMoonTexture(moonTextureName);
		 mMoonMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0)->setTextureName (textureName);
	    mBackMaterial->getBestTechnique ()->getPass (0)->getTextureUnitState (0)->setTextureName (textureName);
*/
	}

	void Moon::initBillboards()
	{

		/*
		 mMoonBB.reset(sceneMgr->createBillboardSet("Caelum/Moon/MoonBB" + uniqueSuffix, 1));
	    mMoonBB->setMaterialName (mMoonMaterial->getName());
	    mMoonBB->setCastShadows (false);
	    mMoonBB->setRenderQueueGroup (CAELUM_RENDER_QUEUE_MOON);
	    mMoonBB->setDefaultDimensions (1.0f, 1.0f);
	    mMoonBB->createBillboard (Ogre::Vector3::ZERO);

	    mBackBB.reset(sceneMgr->createBillboardSet("Caelum/Moon/BackBB" + uniqueSuffix, 1));
	    mBackBB->setMaterialName (mBackMaterial->getName());
	    mBackBB->setCastShadows (false);
	    mBackBB->setRenderQueueGroup (CAELUM_RENDER_QUEUE_MOON_BACKGROUND);
	    mBackBB->setDefaultDimensions (1.0f, 1.0f);
	    mBackBB->createBillboard (Ogre::Vector3::ZERO);
		*/
	}


	void Moon::setPhase(Ogre::Real phase)
	{
	}

	void Moon::update(const Ogre::Vector3& direction,const Ogre::ColourValue &lightColor,const Ogre::ColourValue &bodyColor)
	{
	}


}
